//
//  BGCangDanController.m
//  bigMall
//
//  Created by ios on 16/8/24.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGCangDanController.h"
#import "SZAddImage.h"
#import "BGFaBuViewController.h"


@interface BGCangDanController () {
    
//    NSMutableArray *const arr;
    NSMutableString *str;
    SZAddImage *a;
    
}
@property (nonatomic,strong) NSMutableArray *arr;
@end

@implementation BGCangDanController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"仓单图片";
    
    UIBarButtonItem *a = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(clicked)];
    self.navigationItem.rightBarButtonItem = a;
    
    [self createUI];
    
    // Do any additional setup after loading the view.
}
+ (BGCangDanController *)share {
    
    static BGCangDanController *sharedAccountManagerInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        sharedAccountManagerInstance = [[self alloc] init];
    });
    return sharedAccountManagerInstance;
    
}
- (void)clicked {
    
    for (int i = 0; i < self.imageArrm.count; i++) {
        
        if (i == 0) {
            str = [NSMutableString stringWithFormat:@"%@",self.imageArrm[i]];
        }else {
            str = [NSMutableString stringWithFormat:@"%@,%@",str,self.imageArrm[i]];
        }
        
        //        if (i != 0 || i != self.imageData.count - 1) {
        //            [str insertString:@"," atIndex:j + 3];
        //        }
        
    }
    
    if (self.imageArrm.count == 0) {
        str = [NSMutableString stringWithString:@""];
    }
    [BGFaBuViewController share].storePicStra = str;
    
}
- (void)setImageArrm:(NSMutableArray *)imageArrm {
    
//    _arr = [NSMutableArray array];
//    _imageArrm = imageArrm;
    _imageArrm = imageArrm;
//    _imageArrm = [NSMutableArray arrayWithArray:imageArrm];
//    _arr = _imageArrm;
//    [self clicked];
//
//    NSLog(@"%@",_imageArrm);
    
}
- (void)createUI {
    
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 64 + 64, BGWidth, 1)];
    v.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:v];
    
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(23, 17 + 64, 100, 30)];
    lab.text = @"仓单图片";
    [self.view addSubview:lab];
    
    a = [[SZAddImage alloc] initWithFrame:CGRectMake(27, 156, BGWidth - 27, BGHight - 250)];
    
    [self.view addSubview:a];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewWillDisappear:(BOOL)animated {
    
    for (int i = 0; i < [BGCangDanController share].imageArrm.count; i++) {
        
        if (i == 0) {
            str = [NSMutableString stringWithFormat:@"%@",[BGCangDanController share].imageArrm[i]];
        }else {
            str = [NSMutableString stringWithFormat:@"%@,%@",str,[BGCangDanController share].imageArrm[i]];
        }
        
        //        if (i != 0 || i != self.imageData.count - 1) {
        //            [str insertString:@"," atIndex:j + 3];
        //        }
        
    }
    
    if ([BGCangDanController share].imageArrm.count == 0) {
        str = [NSMutableString stringWithString:@""];
    }
    
    [BGFaBuViewController share].type = @"cangdan";
    [BGFaBuViewController share].storePicStra = str;
    
}
- (void)viewWillAppear:(BOOL)animated {
    [BGCangDanController share].imageArrm = [NSMutableArray array];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
